import time

from PySide6.QtWidgets import QApplication, QMessageBox
from PySide6.QtUiTools import QUiLoader

# 在QApplication之前先实例化
uiLoader = QUiLoader()

class Stats:

    def __init__(self):
        # 再加载界面
        self.ui = uiLoader.load('ui/ui_qlineedit.ui')
        self.ui.lineEdit.setPlaceholderText('这里输入被模仿的信息')
        self.ui.lineEdit.textChanged.connect(self.demo_1)
        self.ui.lineEdit.returnPressed.connect(self.demo_2)

    def demo_1(self):
        text = self.ui.lineEdit.text()
        self.ui.label.setText(text)

    def demo_2(self):
        self.ui.label.setText("输入框中的内容已写入剪切板")
        # 方法可以拷贝当前选中文本到剪贴板，比如
        self.ui.lineEdit.copy()

app = QApplication([])
stats = Stats()
stats.ui.show()
app.exec() # PySide6 是 exec 而不是 exec_